package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 关于会员的常量及枚举类
 */
public class MemberConstant {

    public static final String GENERAL = "general";//普通会员
    public static final String VIP = "vip";//VIP
    public static final String PARTNER = "partner";//店铺合伙人
    public static final String COUNTY_AGENT = "county_agent";//县级代理
    public static final String CITY_AGENT = "city_agent";//市代理



    public enum MemberGrade {
        //GENERAL
        GENERAL(0, "普通会员"),

        //vip
        GROUP_HEAD(1, "团长");



        @EnumValue
        @JsonValue
        private Integer code;
        private String value;

        MemberGrade(Integer code, String value) {
            this.value = value;
            this.code = code;
        }

        public Integer getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }

        public static String getByValue(Integer value) {
            MemberConstant.MemberGrade[] memberLevels = values();
            for (MemberConstant.MemberGrade memberLevel : memberLevels) {
                if (memberLevel.getCode().equals(value)) {
                    return memberLevel.getValue();
                }
            }
            return null;
        }

    }


    /**
     * 会员等级
     * 0---普通会员
     * 1---VIP
     * 2---店铺合伙人
     * 3---县级代理
     * 4---市代理
     */
    public enum MemberLevel {

        GENERAL(0, "普通会员"),//GENERAL

        VIP(1, "VIP"),//vip

        SHOP_PARTNER(2, "平台合伙人"),//PARTNER

        PAETICIPANT(3, "县级代理"),//COUNTY_AGENT

        CITY_AGENT(4, "市级代理");//CITY_AGENT

        @EnumValue
        @JsonValue
        private Integer code;
        private String value;

        MemberLevel(Integer code, String value) {
            this.value = value;
            this.code = code;
        }

        public Integer getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }

        public static String getByValue(Integer value) {
            MemberConstant.MemberLevel[] memberLevels = values();
            for (MemberConstant.MemberLevel memberLevel : memberLevels) {
                if (memberLevel.getCode().equals(value)) {
                    return memberLevel.getValue();
                }
            }
            return null;
        }

    }

    /**
     * 会员注册来源
     */
    public static enum RegisterSource implements IntegerEnum<Integer> {
        /**
         * 0：App注册
         * 1：小程序注册
         * 2：导入
         */
        APP(0, "App"),
        WX(1, "小程序"),
        IMPORT(2, "导入");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RegisterSource(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.RegisterSource getByCode(int code) {
            for (MemberConstant.RegisterSource value : MemberConstant.RegisterSource.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 广告位类型
     */
    public static enum AdLocation implements IntegerEnum<Integer> {
        /**
         * 0：平台
         * 1：商家
         */
        ADMIN(0, "平台"),
        SHOP(1, "商家");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        AdLocation(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.AdLocation getByCode(int code) {
            for (MemberConstant.AdLocation value : MemberConstant.AdLocation.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 用户类型
     */
    public static enum UserType implements IntegerEnum<Integer> {
        /**
         * 0：会员
         * 1：商家
         */
        MEMBER(0, "会员"),
        SHOP(1, "商家"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        UserType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.UserType getByCode(int code) {
            for (MemberConstant.UserType value : MemberConstant.UserType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 性别类型
     */
    public static enum GenderType implements IntegerEnum<Integer> {

        EMPTY(0, "保密"),
        MAN(1, "男"),
        WOMAN(2, "女"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        GenderType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.GenderType getByCode(int code) {
            for (MemberConstant.GenderType value : MemberConstant.GenderType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 认证标签
     */
    public static enum IscccLable implements IntegerEnum<Integer> {
        //智力残疾
        ZHILI_CANJI(0, "智力残疾"),
        SHILI_CANJI(1, "视力残疾"),
        TINGLI_CANJI(2, "听力残疾"),
        YUYANG_CANJI(3, "言语残疾"),
        ZITI_CANJI(4, "肢体残疾"),
        JINGSHENG_CANJI(5, "精神残疾"),


        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        IscccLable(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.IscccLable getByCode(int code) {
            for (MemberConstant.IscccLable value : MemberConstant.IscccLable.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 审核状态
     * 0待审核
     * 1审核通过
     * 2审核不通过
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum VerifyStatus implements IntegerEnum<Integer> {

        //0待审核
        VERIFY_WAIT(0, "待审核"),
        VERIFY_PASS(1, "审核通过"),
        VERIFY_NO_PASS(2, "审核不通过"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        VerifyStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.VerifyStatus getByCode(int code) {
            for (MemberConstant.VerifyStatus value : MemberConstant.VerifyStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 区域类型
     */
    public static enum AreaType implements IntegerEnum<Integer> {
        /**
         * 0：省
         * 1：市
         * 2：区县
         * 3：街道
         * 4：社区
         */
        PROVINCE(0, "省"),
        CITY(1, "市"),
        AREA(2, "区县"),
        STREET(3, "街道"),
        COMMUNITY(4, "社区"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        AreaType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.AreaType getByCode(int code) {
            for (MemberConstant.AreaType value : MemberConstant.AreaType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 第三方身份
     */
    public static enum ThirdType implements IntegerEnum<Integer> {
        /**
         * 0：微信小程序
         * 1：支付宝小程序
         */
        WECHAT(0, "微信小程序"),
        ALIPAY(1, "支付宝小程序"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ThirdType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberConstant.ThirdType getByCode(int code) {
            for (MemberConstant.ThirdType value : MemberConstant.ThirdType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
